﻿Public Class GWaveForm

#Region "Form Movement"
    Private Sub lbl_MouseDown_MoveForm(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles lblTitle.MouseDown, pnlTitleBar.MouseDown
        np = New Point(MousePosition.X - Me.Location.X, MousePosition.Y - Me.Location.Y)
        CType(sender, Control).Capture = True
    End Sub

    Dim np As Point
    Private Sub lbl_MouseMove_MoveForm(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles lblTitle.MouseMove, pnlTitleBar.MouseMove
        If CType(sender, Control).Capture = True Then
            Dim mp As Point = MousePosition
            Dim diff As New Point(mp.X - np.X, mp.Y - np.Y)

            Me.Location = diff
        End If
    End Sub

    Private Sub lbl_MouseUp_MoveForm(ByVal sender As Object, ByVal e As System.EventArgs) Handles lblTitle.MouseUp, pnlTitleBar.MouseUp
        CType(sender, Control).Capture = False
    End Sub
#End Region

#Region "Control Box Buttons"
#Region "Close Button"
    Private m_isOverCloseButton As Boolean
    Private Sub PictureBox1_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles btnClose.MouseDown
        If e.Button = Windows.Forms.MouseButtons.Left Then
            m_isOverCloseButton = True
            btnClose.BackColor = Color.Gray
        End If
    End Sub

    Private Sub btnClose_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnClose.MouseLeave
        If m_isOverCloseButton Then
            btnClose.BackColor = Color.Transparent
            m_isOverCloseButton = False
        End If
    End Sub

    Private Sub PictureBox1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles btnClose.MouseUp
        If m_isOverCloseButton AndAlso e.Button = Windows.Forms.MouseButtons.Left Then
            btnClose.BackColor = Color.Transparent
            Me.Close()
        End If
    End Sub
#End Region
#End Region
#Region "Cursor Changing"
    'Michael
    '19 October 2009
    'TODO: Do we need all these timers?
    'I am not sure what this does so I can't refactor it well.

    Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
        Dim mp As Point = MousePosition
        Dim lp As Point = Me.Location
        Dim diff As New Point(mp.X - np.X, mp.Y - np.Y)
        Me.Height = (mp.Y - Me.Location.Y) + np.Y
        'np = MousePosition
    End Sub
    Private Sub pnlBottomPage_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles pnlBottomPage.MouseDown
        np = New Point(MousePosition.X, (Location.Y + Height) - MousePosition.Y)
        Timer2.Interval = 10
        Timer2.Start()
    End Sub
    Private Sub pnlBottomPage_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles pnlBottomPage.MouseUp
        Timer2.Stop()
    End Sub
    Private Sub Panel8_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles pnlBottomPage.MouseEnter
        Cursor = Cursors.SizeNS
    End Sub

    Private Sub Panel8_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles pnlBottomPage.MouseLeave
        Cursor = Cursors.Default
    End Sub

    Private Sub pnlBottomLeftPage_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles pnlBottomLeftPage.MouseEnter
        Cursor = Cursors.SizeNESW
    End Sub

    Private Sub pnlBottomLeftPage_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles pnlBottomLeftPage.MouseLeave
        Cursor = Cursors.Default
    End Sub
#End Region

#Region "Overrides"
    Public Overrides Property Text() As String
        Get
            Return MyBase.Text
        End Get
        Set(ByVal value As String)
            MyBase.Text = value
            lblTitle.Text = value
        End Set
    End Property
    'Public Shadows ReadOnly Property Controls() As ControlCollection
    '    Get
    '        Return pnlMain.Controls
    '    End Get
    'End Property
#End Region
End Class
